<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

	<head>
		<title>Gimme Filter And Iterate Tests</title>

		<script type = "text/javascript" src = "../jsunit/app/jsUnitCore.js"></script>
		<script type = "text/javascript" src = "../utils/jsunit/jsUnitHelperFunctions.js"></script>
		<script type = "text/javascript" src = "../build/debug/gimme.js"></script>
		
		<script type = "text/javascript">
		
			function test_selectSpansInZooFilterTigers()
			{
				var gObj = Gimme('#zoo span').filter(function(el) { return el.className !== 'tiger'; });
				checkArrays(getM('panda1', 'panda2', 'panda3'), gObj.entities());
			}
			
			function test_selectAllDescendantsOfDivsFilterSpans()
			{
				var gObj = Gimme('div *').filter(function(el) { return el.tagName !== 'SPAN'; });
				checkArrays(getM('tree1', 'tree2', 'ivyPlant1'), gObj.entities());
			}
			
			function test_iterateAllSpansInZoo()
			{
				var str = '';
				Gimme('#zoo span').iterate(function(i)
				{
					str += this.element().innerHTML;
				});
				
				assertEquals('Iterate failed', str, 'Panda1Tiger1Panda2Panda3');
			}
			
			function test_iteratePTagsCheckIndicies()
			{
				var str = '';
				Gimme('p').iterate(function(i)
				{
					str += i + ':' + this.element().tagName.toLowerCase() + '#' + this.element().id + '/';
				});
				
				assertEquals('Iterate failed', str, '0:p#tree1/1:p#tree2/2:p#ivyPlant1/');
			}
		</script>
	</head>

	<body>
		<h1>Gimme Filter And Iterate Tests</h1>

		<div id = "zoo" class = "place man-made">
			<span id = "panda1" class = "panda">Panda1</span>
			<span id = "tiger1" class = "tiger">Tiger1</span>
			<span id = "panda2" class = "panda">Panda2</span>
			<span id = "panda3" class = "panda" foo = "bar">Panda3</span>
		</div>
		<div id = "forest" class = "place natural">
			<p id = "tree1" class = "tree pine">Pine tree 1</p>
			<p id = "tree2" class = "tree oak">Oak tree 1</p>
			<span id = "chipmunk1" class = "mammal chipmunk">Chipmunk 1</span>
			<span id = "gazelle1" class = "mammal gazelle">Gazelle 1</span>
			<p id = "ivyPlant1" class = "ivy poison">Poison Ivy Plant 1</p>
		</div>
	</body>

</html>